<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="/css/register.css"/>


		<title>忘记密码</title>
        <style>
            #earro_tip{
                border: 1px solid red;
                color: red;
                font-size: 15px;
                height: 20px;
                display: none;
            }

        </style>

	</head>
	<body>
		<div class="top">
			<span class="span1">已有账号？<a href="#" class="a2">去登录</a></span>
		</div>
		<div class="div1" align="center">
			
			<div class="mid">
				<span class="mid-password">重置密码</span>
			</div>

			<!--放注册的盒子-->
			<div class="div9">
                <a href="/login/pc_loginPage" class="a1">返回首页</a>
                    <!-- 提示框 -->
                    <div id="earro_tip"></div>
				<form class="layui-form">

					<div class="div3">
						<input type="text" name="certificate" id="certificate"  placeholder="请输入要重置密码的邮箱账号"  class="dongtai"/>
					</div>

					<div class="div4">
						<input type="password" name="token1" id="token1"  placeholder="请输入旧密码" class="yonghu" />
					</div>

					<div class="div4">
						<input type="password" name="token" id="token"  placeholder="请输入新密码" class="yonghu" />
					</div>
					<div class="div5">
						<input type="password" name="new_token" id="new_token"   placeholder="请确认密码" class="shezhi"/>
					</div>
		            
					<div class="div8">
						<input class="tongyi" type="submit" lay-submit lay-filter="submit1" value="确认" />
					</div>
				</form>
			</div>
		</div>
		<div class="footer">
			<a href="#">网易</a>
			<span>|</span>
			<a href="#">联系客服</a>
			<span>|</span>
			<a href="#">帮助</a>
		</div>
	</body>
	<script type="text/javascript" th:src="@{/js/layui/layui.js}"></script>
	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<script>

		let myUrl = localStorage.getItem("myUrl");

		layui.use(['form'], function() {
			var $ = layui.$,
			form = layui.form;
			form.on('submit(submit1)', function(data) {
				console.log(data.field);
				/* 正则判断 */
				if(!/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test($("#certificate").val())){
					layer.msg("请输入正确的邮箱");
					console.log("111");
					return false;
				}
				if($("#token").val()=="" || $("#new_token").val()=="" || $("#token").val()!=$("#new_token").val()){
					layer.msg("密码不一致或为空,请重新输入密码");
					console.log("222");
					return false;
				}


				$.ajax({
					url: myUrl+"/note-user/certificate/update",
					type: 'post',
					data: JSON.stringify(data.field),
					contentType: 'application/json',
					dataType: 'json',
					success: function(d) {
						if(d.rs) {
							layer.msg(d.msg);
						} else {
							layer.msg(d.msg);
						}
					}
				})
				return false;
			})
		})


	</script>

</html>
